Function Comp($list, $result) {
    if ($list) {
        $list | % {
            $newList = Remove-Element $list $_
            Comp $newList ($result + $_)
        }
    } else {
        Test-Answer $result
    }
}

Function Test-Answer($comp) {
    $length = $comp.Count
    $newComp = @()
    for ($i = 0; $i -lt $length; $i++ ) {
        $newComp += $comp[$i] + $i
    }   
    
    if (Test-Duplication $newComp) { return }
    
    $newComp = @()
    for ($i = 0; $i -lt $length; $i++ ) {
        $newComp += $comp[$i] - $i
    }   
    
    if (Test-Duplication $newComp) { return }
    
    Write-Host $comp
}

Function Test-Duplication($list) {
    if (!$list) { return $False }    

    $first = $list[0]
    $rest = $list[1..$list.Count]
    if (Include $first $rest) { return $True }
    return (Test-Duplication $rest)
}

Function Include($e, $list) {
    foreach($one in $list) {
        if ($one -eq $e) { return $True }
    }
    return $False
}

Function Remove-Element($list, $toRemove) {
    $newList = @()
    $list | ? { $_ -ne $toRemove } | % { $newList += $_ }
    $newList
}


Comp @(1,2,3,4,5,6,7,8) @()